﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using PlanningGIS.Framework;
using ESRI.ArcGIS.ADF.BaseClasses;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Geometry;
////using ESRI.ArcGIS.TOCControl;


namespace PlanningGIS.TocContextMenu.Button
{
    /// <summary>
    /// 作用：设置参考比例尺
    /// 作者：
    /// 编写日期：2009-03-25
    /// </summary>
    internal  class ReferenceScaleSet:BaseCommand 
    {
        IApplication m_Application = null;
        public ReferenceScaleSet()
        {
            base.m_caption = "设置参考比例尺";
            base.m_toolTip = base.Caption;
        }
        public override void OnCreate(object hook)
        {
            m_Application = hook as IApplication;
        }
        public override void OnClick()
        {
            (m_Application as IFramework).MapControl.ReferenceScale = (m_Application as IFramework).MapControl.MapScale;
            (m_Application as IFramework).MapControl.Refresh(esriViewDrawPhase.esriViewGeography, null, null);
            (m_Application as IFramework).TOCControl.Update();
        }
        public override bool Enabled
        {
            get
            {
                return (m_Application as IFramework).IsMapCtrlactive;
            }
        }

        public override int Bitmap
        {
            get
            {
                string bitmapResourceName = "PlanningGIS.TocContextMenu.Res." + this.GetType().Name + ".ico";
                System.IO.Stream stream = GetType().Assembly.GetManifestResourceStream(bitmapResourceName);
                if (stream == null) return 0;

                return new Bitmap(stream).GetHbitmap().ToInt32();
            }
        }
    }
    
}
